/**
 * Created with IntelliJ IDEA.
 * Description:2、通过实现Runnable接口实现多线程
 * User: 东莞呵呵
 * Date:2022-08-30
 * Time:10:21
 */

class MyRunnable implements Runnable{

    @Override
    public void run() {
        while (true){
            System.out.println("run1");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class Demo2 {

    public static void main(String[] args) {
        MyRunnable myRunnable = new MyRunnable();
        Thread thread=new Thread(myRunnable,"我的线程");
        thread.start();

        while(true){
            System.out.println("run2");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
